<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="../common.jsp"%>
<%@ page import="cn.firstsoft.firstframe.web.support.UserOnlineListener"%>
<%@ page import="cn.firstsoft.firstframe.admin.PropertyFile"%>
<%@ page import="cn.firstsoft.firstframe.util.ContextUtils,cn.firstsoft.firstframe.util.Version"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@page import="cn.firstsoft.firstframe.web.FirstFrameBeanFactory"%>
<%@page import="java.util.List"%>
<%@page import="org.springside.modules.security.vo.LicVO"%>
<%@page import="org.springside.core.utils.DateUtil"%>
<%@page import="cn.firstsoft.firstframe.util.EcpModuleUseNum"%>
<%@page import="cn.firstsoft.firstframe.util.EcpPermInfoVO"%>
<%@page import="org.springside.modules.security.service.logic.UserManager"%>
<%@page import="java.util.ArrayList"%>
<html>
<head>
<title>管理控制台 - 服务信息</title>
<%@ include file="/common/meta2.jsp"%>
<link href="../style.css" type="text/css" rel=stylesheet>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="#FFFFFF">


<FORM method="post" action="license_update.jsp" encType="multipart/form-data">

<%
	String limitUserCount = "";
	String limitDate = "";
	String companyName = "";
	String bindMac = "";
	String macStr ="";
	String serviceDate = "";
	String version = "";
	String moduleStr = "";
	moduleStr = "";
	List<EcpPermInfoVO> moduleInfos = new ArrayList<EcpPermInfoVO>();
	List<EcpPermInfoVO> interfaceInfos = new ArrayList<EcpPermInfoVO>();
	Integer helperOnlineCount = 0;
	Integer mobileOfficeCount = 0;
   	try{
	 limitUserCount = ContextUtils.getLicenseNum().toString();
	 limitDate = DateUtil.format(ContextUtils.getExpireDate(),"yyyy-MM-dd HH:mm:ss");
	 companyName = ContextUtils.getCustomName();
	 bindMac = ContextUtils.getSoftwareCode();
	 macStr = ContextUtils.getLocalSoftwareCode();
	 serviceDate = DateUtil.format(ContextUtils.getServiceDate(),"yyyy-MM-dd HH:mm:ss");
	 version = ContextUtils.getVersionNum() + "  " + ContextUtils.getVersion();
	 moduleStr = (String)ContextUtils.getVariable("moduleStr");
	 moduleStr = moduleStr.replaceAll("@@", ",").replaceAll("@", "");
	 EcpModuleUseNum ecpModuleUseNum = EcpModuleUseNum.getInstance();
     moduleInfos = ecpModuleUseNum.getEcpModulePermInfo();
     interfaceInfos = ecpModuleUseNum.getEcpInterfacePermInfo();
     helperOnlineCount = UserOnlineListener.getClientOnlineUsers();
     UserManager userManager = (UserManager)FirstFrameBeanFactory.getBean("userManager");
     mobileOfficeCount = userManager.getMobileUsers();
   }catch(Exception e){
	   e.printStackTrace();
   }   
%>
 
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=2>
		许可证书信息
		</TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    软件特征码:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%=macStr%> 
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	<!-- 
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    绑定机器码:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%=bindMac%> 
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	 -->
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    授权公司:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%=companyName%> 
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>	
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    许可用户数:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%=limitUserCount%> 

	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    许可期限:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%=limitDate%>
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	<TR>
	<TD class=tabDetailViewDL vAlign=top width="15%">
	    服务期限:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%=serviceDate%>
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    授权版本:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
           <%=version %>
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
		<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    授权模块简码:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%" style="text-align:left;table-layout:fixed;word-break:break-all">	    
          <%=moduleStr%>
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    授权接口:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%" style="text-align:left;table-layout:fixed;word-break:break-all">	    
          <c:set var="interfaceInfos" value="<%=interfaceInfos%>" />
          <c:forEach items="${interfaceInfos}" var="interfaceInfo" varStatus="status">
            <c:if test="${status.count>1}">
  			  ,
  			</c:if>
            <spring:message code="module_${moduleInfo.i18nKey}" text="${interfaceInfo.name}"/>
          </c:forEach>
          
          
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    在线用户数:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
	      <c:set var="moduleInfos" value="<%=moduleInfos%>" />

  	<table width="100%" align="center" >
		<tr class=listViewPaginationTdS1>
			<TH listViewPaginationTdS1  align="left">模块名称</TH>
			<TH listViewPaginationTdS1  align="left">许可站点数</TH>
			<TH listViewPaginationTdS1  align="left">在线人数</TH>
			<TH listViewPaginationTdS1  align="left">模块名称</TH>
			<TH listViewPaginationTdS1  align="left">许可站点数</TH>
			<TH listViewPaginationTdS1  align="left">在线人数</TH>
		</tr>
		<tr>
  		<c:forEach items="${moduleInfos}" var="moduleInfo" varStatus="status">
  			 <c:if test="${status.count>0&&(status.count%2==1)}">
  			  </tr>  <tr>
  			</c:if>
  				
			<td width="20%"  align="left">	
			  <spring:message code="module_${moduleInfo.i18nKey}" text="${moduleInfo.name}"/>
			  <c:if test="${moduleInfo.licKey eq 'helper'}">  </c:if>
			</td>
			<td width="15%"  align="left">${moduleInfo.licNum}</td>
			<td width="15%"  align="left">
			  <c:choose>
				<c:when test="${moduleInfo.licKey eq 'helper'}">
				  <%=helperOnlineCount%>
				</c:when>
				<c:when test="${moduleInfo.licKey eq 'mobileoffice'}">
				  <%=mobileOfficeCount%>
				</c:when>
				<c:otherwise> 
				  ${moduleInfo.concurrentNum}
				</c:otherwise>
			 </c:choose>
			</td>
  		</c:forEach>
  	  <tr>
		<td colspan="4"> <font color="red"> 办公助手:二个在线人数占一个许可站点数。</font></td>
	 </tr>
  	</table>  	
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
	<TR>
		<TD colSpan=3>
		&nbsp;
		</TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=2>
		上传License
		</TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    选择License:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
		<input type="file" style="width:350px;" name="licfile"></input> <input type="submit" value="上传">
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;
	    </TD>
	</TR>
  </TBODY>
</TABLE>
</FORM>

</body>
</html>